﻿using System;
using System.Collections.Generic;
using System.Text;
using Axis.Dao.Base;
using Axis.BusinessObject.Core;
using FWS.Framework.Log;
using Axis.Dao.SQL;
using Axis.BusinessObject.Research;

namespace Axis.Dao.Research
{
    public class CResearchDao : CDaoBase
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" ProjectID="1" />
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CQuestionaire> GetQuestionaire(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CQuestionaire> list = CallFunctionWithList<CQuestionaire>(CSystemFunction.GetQuestionaire, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue UserID="" Session="" Action="INSERT|UPDATE|DELETE"   ID="1" QuestionText="" Type="1"/>
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionQuestionaire(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionQuestionaire, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" ProjectID="1" />
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CProject> GetProject(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CProject> list = CallFunctionWithList<CProject>(CSystemFunction.GetProject, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue UserID="" Session="" Action="INSERT|UPDATE|DELETE"   ID="1" Code="" Name="" Description="" ExpriedDate=""/>
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionProject(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionProject, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" ProjectID="1" />
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CResponseOption> GetResponseOption(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CResponseOption> list = CallFunctionWithList<CResponseOption>(CSystemFunction.GetResponseOption, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue UserID="" Session="" Action="INSERT|UPDATE|DELETE"   ID="1" Code="" Name="" Description="" ExpriedDate=""/>
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionResponseOption(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionResponseOption, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" ProjectID="1" />
        /// </param>
        /// <returns></returns>
        public IList<CQuestionPath> GetQuestionPath(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CQuestionPath> list = CallFunctionWithList<CQuestionPath>(CSystemFunction.GetQuestionPath, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetQuestionPath", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ID="1" QuestionPathID="1" />
        /// </param>
        /// <returns></returns>
        public IList<CQuestionPathDetail> GetQuestionPathDetail(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CQuestionPathDetail> list = CallFunctionWithList<CQuestionPathDetail>(CSystemFunction.GetQuestionPathDetail, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetQuestionPathDetail", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue Action="INSERT|DELETE|UPDATE"  ID="1" ProjectID="1" Code="" Name="" Description="" NextQuestionnaireID="1"/>
        /// <Detail QuestionnaireID="1" ResponseValue="1" />
        /// <Detail QuestionnaireID="1" ResponseValue="2" />
        /// <Detail QuestionnaireID="2" ResponseValue="1" />
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionQuestionPath(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionQuestionPath, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("ActionQuestionPath", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" MemberGroupID="1" [CriteriaID="1"] />
        /// </param>
        /// <returns></returns>
        public IList<CMemberGroupDetail> GetMemberGroupDetail(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CMemberGroupDetail> list = CallFunctionWithList<CMemberGroupDetail>(CSystemFunction.GetMemberGroupDetail, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetQuestionPathDetail", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" />
        /// </param>
        /// <returns></returns>
        public IList<CGift> GetGift(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CGift> list = CallFunctionWithList<CGift>(CSystemFunction.GetGift, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetGift", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue Action="INSERT|DELETE|UPDATE"  ID="1" Code="" Name="" Image="" Description="" Mark="1" Amount="1" Manufactor="" Quantity="1" GroupID="1"/>
        /// <Detail QuestionnaireID="1" ResponseValue="1" />
        /// <Detail QuestionnaireID="1" ResponseValue="2" />
        /// <Detail QuestionnaireID="2" ResponseValue="1" />
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionGift(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionGift, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("ActionGift", ex.Message);
                return null;
            }
        }

        public CApplicationMessage ActionUserResponse(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.UpdateUserResponse, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("UpdateUserResponse", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ProjectID="11" Context="USERSAVED"/>
        /// </param>
        /// <returns></returns>
        public IList<CUserResponseDetail> GetUserResponse(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CUserResponseDetail> list = CallFunctionWithList<CUserResponseDetail>(CSystemFunction.GetUserResponse, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetUserResponse", ex.Message);
                return null;
            }
        }

        public CDataTable GetProjectResponseExport(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CDataTable obj = CallFunctionWithDataTable(CSystemFunction.GetProjectResponseExport, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetProjectResponseExport", ex.Message);
                return null;
            }
        }

        public CDataTable GetDataExport(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CDataTable obj = CallFunctionWithDataTable(CSystemFunction.GetDataExport, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetDataExport", ex.Message);
                return null;
            }
        }

        public IList<CUserResponse> GetProjectResponseExportInObject(string pInputValue)
        {
            try
            {
                
                COutputValue output = new COutputValue();
                IList<CUserResponse> list = CallFunctionWithList<CUserResponse>(CSystemFunction.GetProjectResponseExport, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetProjectResponseExport", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue ProjectID="100" Context="ProjectVote"/>
        /// Neu lay theo danh sach thi ko co ID
        /// </param>
        /// <returns></returns>
        public IList<CChartData> GetChartData(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CChartData> list = CallFunctionWithList<CChartData>(CSystemFunction.GetChartData, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetCustomer", ex.Message);
                return null;
            }
        }


        /// <summary>
        /// <InputValue Action="INSERT|DELETE|UPDATE"  ID="1" Code="" Name="" Image="" Description="" Mark="1" Amount="1" Manufactor="" Quantity="1" GroupID="1"/>
        /// <Detail QuestionnaireID="1" ResponseValue="1" />
        /// <Detail QuestionnaireID="1" ResponseValue="2" />
        /// <Detail QuestionnaireID="2" ResponseValue="1" />
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionMemberGift(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionMemberGift, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("ActionGift", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ProjectID="52" [ID="1"]/>
        /// </param>
        /// <returns></returns>
        public IList<CQuestionnaireCondition> GetQuestionnaireConditions(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CQuestionnaireCondition> list = CallFunctionWithList<CQuestionnaireCondition>(CSystemFunction.GetQuestionnaireConditions, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetUserResponse", ex.Message);
                return null;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pInputValue"> 
        /// <InputValue UserID="1" ProjectID="52" QuestionnaireConditionsID="1" />
        /// </param>
        /// <returns></returns>
        public IList<CQuestionnaireConditionDetail> GetQuestionnaireConditionsDetails(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                IList<CQuestionnaireConditionDetail> list = CallFunctionWithList<CQuestionnaireConditionDetail>(CSystemFunction.GetQuestionnaireConditionsDetails, pInputValue, ref output);
                LastOutputValue = output;

                return list;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("GetUserResponse", ex.Message);
                return null;
            }
        }

        /// <summary>
        /// <InputValue Action="INSERT|DELETE|UPDATE" ProjectID="50"  ID="1" QuestionnaireID="1" Code="" Name="" Description="" />
        /// <Detail GroupZOrder="1" GroupMethod="1" Method="0" IsNot="0" ResponseValue="1" ResponseText="ABC" IsNotQuestionnaireID="0" NextQuestionnaireID="-100" />
        /// <Detail GroupZOrder="1" GroupMethod="1" Method="0" IsNot="0" ResponseValue="2" ResponseText="ABC" IsNotQuestionnaireID="0" NextQuestionnaireID="-100" />
        /// <Detail GroupZOrder="1" GroupMethod="1" Method="0" IsNot="0" ResponseValue="3" ResponseText="ABC" IsNotQuestionnaireID="0" NextQuestionnaireID="-100" />
        /// </summary>
        /// <param name="pInputValue">
        /// </param>
        /// <returns></returns>
        public CApplicationMessage ActionQuestionnaireConditions(string pInputValue)
        {
            try
            {
                COutputValue output = new COutputValue();
                CApplicationMessage obj = CallFunction<CApplicationMessage>(CSystemFunction.ActionQuestionnaireConditions, pInputValue);
                return obj;
            }
            catch (Exception ex)
            {
                CLogManager.WriteDAL("ActionGift", ex.Message);
                return null;
            }
        }
    }
}
